package com.zhongkeruan.product.exception;

import com.zhongkeruan.common.constants.StatusCode;
import com.zhongkeruan.common.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author yangyao
 * @Description: 统一异常处理
 * @date 2019/1/16 11:24
 */
@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(value = Exception.class)
    public Result errorHandler(Exception ex) {
        return new Result(StatusCode.ERROR,"未知异常");
    }

    @ExceptionHandler(value = TimeOutException.class)
    public Result handlerTimeOutException(TimeOutException ex) {
        return new Result(StatusCode.TIMEOUT,"请求超时");
    }
}
